<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
 <head>
  <meta http-equiv="content-type" content="text/html; charset=UTF-8">
  <title>Replace regular expression with multibyte support</title>
<link media="all" rel="stylesheet" type="text/css" href="styles/03e73060321a0a848018724a6c83de7f-theme-base.css" />
<link media="all" rel="stylesheet" type="text/css" href="styles/03e73060321a0a848018724a6c83de7f-theme-medium.css" />

 </head>
 <body class="docs"><div class="navbar navbar-fixed-top">
  <div class="navbar-inner clearfix">
    <ul class="nav" style="width: 100%">
      <li style="float: left;"><a href="function.mb-ereg-replace-callback.html">« mb_ereg_replace_callback</a></li>
      <li style="float: right;"><a href="function.mb-ereg-search-getpos.html">mb_ereg_search_getpos »</a></li>
    </ul>
  </div>
</div>
<div id="breadcrumbs" class="clearfix">
  <ul class="breadcrumbs-container">
    <li><a href="index.html">PHP Manual</a></li>
    <li><a href="ref.mbstring.html">多字节字符串 函数</a></li>
    <li>Replace regular expression with multibyte support</li>
  </ul>
</div>
<div id="layout">
  <div id="layout-content"><div id="function.mb-ereg-replace" class="refentry">
 <div class="refnamediv">
  <h1 class="refname">mb_ereg_replace</h1>
  <p class="verinfo">(PHP 4 &gt;= 4.2.0, PHP 5, PHP 7, PHP 8)</p><p class="refpurpose"><span class="refname">mb_ereg_replace</span> &mdash; <span class="dc-title">Replace regular expression with multibyte support</span></p>

 </div>
   
 <div class="refsect1 description" id="refsect1-function.mb-ereg-replace-description">
  <h3 class="title">说明</h3>
  <div class="methodsynopsis dc-description">
   <span class="methodname"><strong>mb_ereg_replace</strong></span>(<br>&nbsp;&nbsp;&nbsp;&nbsp;<span class="methodparam"><span class="type">string</span> <code class="parameter">$pattern</code></span>,<br>&nbsp;&nbsp;&nbsp;&nbsp;<span class="methodparam"><span class="type">string</span> <code class="parameter">$replacement</code></span>,<br>&nbsp;&nbsp;&nbsp;&nbsp;<span class="methodparam"><span class="type">string</span> <code class="parameter">$string</code></span>,<br>&nbsp;&nbsp;&nbsp;&nbsp;<span class="methodparam"><span class="type">?</span><span class="type"><span class="type">string</span><span class="type"></span></span> <code class="parameter">$options</code><span class="initializer"> = <strong><code>null</code></strong></span></span><br>): <span class="type"><span class="type">string</span>|<span class="type"><span class="type false">false</span></span>|<span class="type">null</span></span></div>

  <p class="simpara">
   Scans <code class="parameter">string</code> for matches to
   <code class="parameter">pattern</code>, then replaces the matched text
   with <code class="parameter">replacement</code>  
  </p>
 </div>


 <div class="refsect1 parameters" id="refsect1-function.mb-ereg-replace-parameters">
  <h3 class="title">参数</h3>
  <p class="para">
   <dl>
    
     <dt>
<code class="parameter">pattern</code></dt>

     <dd>

      <p class="para">
       The regular expression pattern.
      </p>
      <p class="para">
       Multibyte characters may be used in <code class="parameter">pattern</code>.
      </p>
     </dd>

    
    
     <dt>
<code class="parameter">replacement</code></dt>

     <dd>

      <p class="para">
       The replacement text.
      </p>
     </dd>

    
    
     <dt>
<code class="parameter">string</code></dt>

     <dd>

      <p class="para">
       The <span class="type">string</span> being checked.
      </p>
     </dd>

    
    
     <dt>
<code class="parameter">options</code></dt>

     <dd>

      <span class="simpara">
       The search option. See <span class="function"><a href="function.mb-regex-set-options.html" class="function">mb_regex_set_options()</a></span> for explanation.
      </span>
     </dd>

    
   </dl>

  </p>
 </div>

 
 <div class="refsect1 returnvalues" id="refsect1-function.mb-ereg-replace-returnvalues">
  <h3 class="title">返回值</h3>
  <p class="para">
   The resultant <span class="type">string</span> on success, or <strong><code>false</code></strong> on error.
   If <code class="parameter">string</code> is not valid for the current encoding, <strong><code>null</code></strong>
   is returned.
  </p>
 </div>


 <div class="refsect1 changelog" id="refsect1-function.mb-ereg-replace-changelog">
  <h3 class="title">更新日志</h3>
  <p class="para">
   <table class="doctable informaltable">
    
     <thead>
      <tr>
       <th>版本</th>
       <th>说明</th>
      </tr>

     </thead>

     <tbody class="tbody">
      <tr>
       <td>8.0.0</td>
       <td>
        <code class="parameter">options</code> is nullable now.
       </td>
      </tr>

      <tr>
       <td>7.1.0</td>
       <td>
        The function checks whether <code class="parameter">string</code> is valid for the
        current encoding.
       </td>
      </tr>

      <tr>
       <td>7.1.0</td>
       <td>
        The <code class="literal">e</code> modifier has been deprecated.
       </td>
      </tr>

     </tbody>
    
   </table>

  </p>
 </div>


 <div class="refsect1 notes" id="refsect1-function.mb-ereg-replace-notes">
  <h3 class="title">注释</h3>
  
  <blockquote class="note"><p><strong class="note">注意</strong>: <p class="para"><span class="function"><a href="function.mb-regex-encoding.html" class="function">mb_regex_encoding()</a></span>
指定的内部编码或字符编码将会当作此函数用的字符编码。</p></p></blockquote>
  <div class="warning"><strong class="warning">警告</strong><p class="para">处理非信任的输入时从不使用
<code class="literal">e</code> 修饰符，就不会转码（即调用 <span class="function"><a href="function.preg-replace.html" class="function">preg_replace()</a></span>）。不注意这些会很可能会导致应用程序引发远程代码执行的漏洞。</p></div>
 </div>


 <div class="refsect1 seealso" id="refsect1-function.mb-ereg-replace-seealso">
  <h3 class="title">参见</h3>
  <p class="para">
   <ul class="simplelist">
    <li class="member"><span class="function"><a href="function.mb-regex-encoding.html" class="function" rel="rdfs-seeAlso">mb_regex_encoding()</a> - Set/Get character encoding for multibyte regex</span></li>
    <li class="member"><span class="function"><a href="function.mb-eregi-replace.html" class="function" rel="rdfs-seeAlso">mb_eregi_replace()</a> - Replace regular expression with multibyte support ignoring case</span></li>
   </ul>
  </p>
 </div>


</div></div></div></body></html>